<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page isELIgnored="false" %>
<%@ include file="/WEB-INF/views/common/includes.jsp" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
	
<%-- ID --%>
<form:hidden path="user.id"/>
<%-- EMAIL --%>
<div class="span-4">
  <label for="user.email"><fmt:message key="user.field.email"/></label>
</div>
<div class="span-12 last">
  <form:input id="user.email" path="user.email" />
</div>	
<%-- PASSWORD --%>
<div class="span-4">
  <label for="user.password"><fmt:message key="user.field.password"/></label>
</div>
<div class="span-12 last">
  <form:input id="user.password" path="user.password" />
</div>	
<%-- NAME --%>
<div class="span-4">
  <label for="user.name"><fmt:message key="user.field.name"/></label>
</div>
<div class="span-12 last">
  <form:input id="user.name" path="user.name" />
</div>	
<%-- SURNAME --%>
<div class="span-4">
  <label for="user.surname"><fmt:message key="user.field.surname"/></label>
</div>
<div class="span-12 last">
  <form:input id="user.surname" path="user.surname" />
</div>	
<%-- NICKNAME --%>
<div class="span-4">
  <label for="user.nickname"><fmt:message key="user.field.nickname"/></label>
</div>
<div class="span-12 last">
  <form:input id="user.nickname" path="user.nickname" />
</div>	

<%-- ORGANIZATION (ROLE_ROOT) --%>
<sec:authorize ifAllGranted="ROLE_ROOT">
<div class="span-4">
  <label for="user.organization"><fmt:message key="user.field.organization"/></label>
</div>
<div class="span-12 last">
  <form:select id="user.organization" path="user.organizationId">
    <form:option value=""></form:option>
    <form:options items="${organizations}" itemLabel="name" itemValue="id"/>
  </form:select>
</div>	
<%-- ADMIN of organization (ROLE_ROOT) --%>
<div class="span-4">
  <label for="user.admin"><fmt:message key="user.field.admin"/></label>
</div>
<div class="span-12 last">
  <form:checkbox id="user.admin" path="user.admin" />
</div>
</sec:authorize>

<%-- ORGANIZATION (ROLE_MANAGER) --%>
<sec:authorize ifAllGranted="ROLE_MANAGER">
<div class="span-4">
  <label for="user.organization"><fmt:message key="user.field.organization"/></label>
</div>
<div class="span-12 last">
  <form:select id="user.organization" path="user.organizationId">
    <form:option value="${organization.id}" label="${organization.name}" title="${organization.name}"></form:option>
  </form:select>
</div>	
<%-- ADMIN of organization (ROLE_MANAGER) --%>
<div class="span-4">
  <label for="user.admin"><fmt:message key="user.field.admin"/></label>
</div>
<div class="span-12 last">
  <form:checkbox id="user.admin" path="user.admin" />
</div>
</sec:authorize>

<sec:authorize ifAllGranted="ROLE_USER">
<div class="span-4">
  <label for="user.organization"><fmt:message key="user.field.organization"/></label>
</div>
<div class="span-12 last">
  <form:select id="user.organization" path="user.organizationId">
    <form:option value="${organization.id}" label="${organization.name}"></form:option>
  </form:select>
</div>	
<%-- ADMIN of organization --%>
<div class="span-4">
  <label for="user.admin"><fmt:message key="user.field.admin"/></label>
</div>
<div class="span-12 last">
  <form:checkbox id="user.admin" path="user.admin" disabled="true"/>
</div>
</sec:authorize>